package genetic;

public class TournamentSelect implements Select {
	int size;
	public TournamentSelect(int size){
		this.size = size;
	}
	
	@Override
	public Individual select(Population pop) {
		Individual best = pop.getAny();
		for (int i = 1; i < size; i++) {
			Individual contender = pop.getAny();
			if (contender.fitness() < best.fitness())
				best = contender;
		}
		return best.clone();
	}

	@Override
	public void prepare(Population pop) {
		//nao faz nada
	}

}
